<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue3 兄弟组件传值-状态提升</title>
</head>
<body>
  <div id="app">
    <content :type="type"></content>
    <my-footer @change="getVal"></my-footer>
  </div>
</body>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
  

  const Content = {
    template: `<div>{{ type }}</div>`,
    props:['type']
  }

  const Footer = {
    template: `
      <footer>
        <ul>
          <li @click="changeType('首页')">首页</li>  
          <li @click="changeType('分类')">分类</li>  
          <li @click="changeType('购物车')">购物车</li>  
          <li @click="changeType('我的')">我的</li>  
        </ul>
      </footer>
    `,
    methods: {
        changeType(type){
            this.$emit('change',type)
        }
    },
  }
  const {createApp} = Vue
  const app = createApp({
      components:{
        content:Content,
        myFooter:Footer
      },
      data(){
        return{
            type:'首页'
        }
      },
      methods: {
        getVal(type){
            this.type = type
        }
      },

  })
  app.mount('#app')
  
</script>
</html>